package main

import (
	"fmt"
	"net"
)

func main() {
	tcpaddr, err := net.ResolveTCPAddr("tcp4", "127.0.0.1:8845")
	if err != nil {
		panic(err)
	}

	conn, err := net.DialTCP("tcp", nil, tcpaddr) //链接
	if err != nil {
		panic(err)
	}

	for {

		var inputString string
		fmt.Scanln(&inputString)

		conn.Write([]byte(inputString))
		buf := make([]byte, 1024)

		n, _ := conn.Read(buf)
		fmt.Println(string(buf[:n]))

	}

}
